package com.mcc.myapplication

fun main() {
    // for 循环可以对任何提供迭代器（iterator）的对象进行遍历
    val ints = listOf(2, 3, 4, 5, 6)
    for (item: Int in ints) {
        print(item)
    }
    println()

    for (i in 1..3) {
        print(i)
    }
    println()
    for (i in 6 downTo 0 step 2) {
        print(i)
    }
    println()

    val array = arrayOf("a", "b", "c")
    for (i in array.indices) {
        print(array[i])
    }
    println()
    for ((index, value) in array.withIndex()) {
        println("the element at $index is $value")
    }
}